//
//  LLStatusOriginalView.swift
//  新浪微博
//
//  Created by mac on 16/5/24.
//  Copyright © 2016年 mac.com. All rights reserved.
//

import UIKit
import SDWebImage
class LLStatusOriginalView: UIView {
    var status: LLStatusViewModel?{
        didSet{
        headIcon.sd_setImageWithURL(status?.headImageURL)
            nameLabel.text = status?.status?.user?.name
            timeLabel.text = status?.status?.created_at
            sourceLabel.text = status?.status?.source
            contentLabel.text = status?.status?.text
            //认证图片 需要处理数据
            verifiedImageView.image = status?.veritiedImage
            mbrankImageView.image = status?.mbrankImage
            pictureView.pictures = status?.status?.pic_urls
            //微博来源 需要处理数据
            sourceLabel.text = status?.sourceText
            //微博时间 数据处理
            timeLabel.text = status?.time
            print(timeLabel)
        }
    }
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
//        self.backgroundColor = UIColor.redColor()
//        timeLabel.backgroundColor = UIColor.redColor()
        setupUI()
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    //设置约束
    private func setupUI(){
        addSubview(headIcon)
        addSubview(verifiedImageView)
        addSubview(nameLabel)
        addSubview(mbrankImageView)
        addSubview(timeLabel)
        addSubview(sourceLabel)
        addSubview(contentLabel)
        addSubview(pictureView)
        headIcon.snp_makeConstraints { (make) in
            make.top.left.equalTo(self).offset(StatusCellMargin)
            make.height.equalTo(40)
            make.width.equalTo(40)
        }
        
        verifiedImageView.snp_makeConstraints { (make) in
            make.right.bottom.equalTo(headIcon)
        }
        nameLabel.snp_makeConstraints { (make) in
            make.top.equalTo(headIcon.snp_top)
            make.left.equalTo(headIcon.snp_right).offset(StatusCellMargin)
        }
        
        mbrankImageView.snp_makeConstraints { (make) in
            make.top.equalTo(headIcon.snp_top)
            make.left.equalTo(nameLabel.snp_right).offset(StatusCellMargin)
        }
        timeLabel.snp_makeConstraints { (make) in
            make.left.equalTo(headIcon.snp_right).offset(StatusCellMargin)
            make.bottom.equalTo(headIcon.snp_bottom)
        }
        sourceLabel.snp_makeConstraints { (make) in
            make.left.equalTo(timeLabel.snp_right).offset(StatusCellMargin)
            make.bottom.equalTo(headIcon.snp_bottom)
        }
        
        contentLabel.snp_makeConstraints { (make) in
            make.top.equalTo(headIcon.snp_bottom).offset(StatusCellMargin)
            make.left.equalTo(headIcon.snp_left)
        }
        pictureView.snp_makeConstraints { (make) in
            make.top.equalTo(contentLabel.snp_bottom).offset(StatusCellMargin)
            make.left.equalTo(contentLabel.snp_left)
            //设置测试大小
            make.size.equalTo(CGSize(width: 100, height: 100))
        }
        

        
        //给原创微博底部添加约束
        self.snp_makeConstraints { (make) -> Void in
            make.bottom.equalTo(contentLabel.snp_bottom).offset(StatusCellMargin)
        }
        
    
    }
    
    //懒加载
    private lazy var headIcon:UIImageView = UIImageView(image: UIImage(named: "avatar_default_big"))
    private lazy var verifiedImageView: UIImageView = UIImageView(image: UIImage(named: "avatar_vip"))
    private lazy var mbrankImageView: UIImageView = UIImageView(image: UIImage(named: "common_icon_membership"))
    private lazy var timeLabel: UILabel = UILabel(title: "22:22", font: 10, textColor: UIColor.orangeColor())
    private lazy var sourceLabel: UILabel = UILabel(title: "布鲁斯", font: 10, textColor: UIColor.darkGrayColor())
    private lazy var nameLabel: UILabel = UILabel(title: "这总部会有吧", font: 14, textColor: UIColor.darkGrayColor())
    private lazy var contentLabel: UILabel = UILabel(title: "不管在贴吧的哪个角落，海吧是你坚强的后盾不管在贴吧的哪个角落，海吧是你坚强的后盾不管在贴吧的哪个角落，海吧是你坚强的后盾不管在贴吧的哪个角落，海吧是你坚强的后盾不管在贴吧的哪个角落，海吧是你坚强的后盾不管在贴吧的哪个角落，海吧是你坚强的后盾不管在贴吧的哪个角落，海吧是你坚强的后盾不管在贴吧的哪个角落", font: 14, textColor: UIColor.darkGrayColor(), alignment: .Left)
    //配图视图
    private lazy var pictureView: LLStatusPictureView = LLStatusPictureView()

}
